package reflect;

import java.util.Arrays;

/**
 * JDK5之后，java推出了一个特性:变长参数
 */
public class ArgDemo {
    public static void main(String[] args) {
        /*
            doSome(new String[]{"one"});
            doSome(new String[]{"one","two"});
            doSome(new String[]{"one","two","three"});
            doSome(new String[]{"one","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three"});
         */
        doSome(1,"one");
        doSome(1,"one","two");
        doSome(1,"one","two","three");
        doSome(1,"one","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three");
    }

/*
    变长参数只能是方法的最后一个参数
    public static void doSome(int a,String... s) 可以
    public static void doSome(String... s,int a) 不可以
    public static void doSome(int... a,String... s) 不可以

    变长参数会被编译器改为数组
    public static void doSome(String[] s){
 */
    public static void doSome(int a,String... s){
        System.out.println(s.length);
        System.out.println(Arrays.toString(s));
    }
}
